from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
import random

op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches', ['enable-automation'])
op.add_experimental_option('useAutomationExtension', False)
op.add_argument("--start-maximized")
driver = webdriver.Chrome(options=op)

driver.get(r"http://wwww.baidu.com")

ele = driver.find_element(By.CSS_SELECTOR,"#kw")
ele.send_keys("自动化")
sleep(2)
randomNumber = random.randint(1,10)
for i in range(randomNumber):
    ele.send_keys(Keys.DOWN)
    sleep(1)
ele.send_keys(Keys.ENTER)
sleep(3)

ele = driver.find_element(By.CSS_SELECTOR,"#kw").get_attribute("value")
sleep(2)
assert ele in driver.title


driver.quit()